using System.Collections.Generic;
using NUnit.Framework;
using RMH.DataAccess;
using RMH.Entities;
using RMH.Web;
using RMH.UnitTests;

namespace RMH.IntegrationTests.Repository
{
    [TestFixture]
    public class RoomRepository_when_getting_a_room : TransactionalRepositoryBase<RoomRepository>
    {
        private StayRepository stayRepository = Container.Resolve<StayRepository>();
        private Room room;
        private Stay firstStay;
        private Stay secondStay;
        private IList<Stay> returnedStays;

        public override void establish_context()
        {
            base.establish_context();
            room = repository.GetFirst();
            firstStay = new Stay { Room = room };
            secondStay = new Stay { Room = room };
            stayRepository.Save(firstStay);
            stayRepository.Save(secondStay);            
        }

        public override void because()
        {
            repository.Clear();
            room = repository.GetByID(room.Id);
        }

        [Test]
        public void can_load_all_stays()
        {
            room.Stays.ShouldContain(firstStay);
            room.Stays.ShouldContain(secondStay);
        }
    }
}